package com.thinkingdata.datax.plugin.writer.util;

import com.google.common.collect.ImmutableSet;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Constants {


   /**
   * @describe: 表类型：user,event
   */
   public final static String USER = "user";
   public final  static String EVENT="event";


   /**
   * @describe: 接入方式类型：http,kafka
   */
   public final static String HTTP="http";
   public final static String KAFKA="kafka";





   public final static int TIMEOUT_SECONDS = 15;

   public final static int SOCKET_TIMEOUT_INSECOND = 172800;

   public static final String LOGGER_NAME = "console-print";

   public static final String USER_VIEW_TABLE_PREFIX = "v_user_";

   public static final String USER_SNAPSHOT_TABLE_PREFIX = "user_snapshot_";

   public static final Map<String,String> SUPPORT_SOURCE_MAP = new HashMap<>();

   public static final Map<String,String> SOURCE_HIVE_COL_TYPE_MAP = new HashMap<>();


   public static final Set<String> TA_SYSTEM_COLUMN_SET = ImmutableSet.copyOf(new String[]{"#account_id","#distinct_id","#type","#ip","#time","#event_name"});

   public static final String DATAX_CONFIG_TEMPLATE = "{\n" +
           "  \"job\": {\n" +
           "    \"setting\": {\n" +
           "      \"speed\": {\n" +
           "        \"channel\": 1\n" +
           "      }\n" +
           "    },\n" +
           "    \"content\": [\n" +
           "      {\n" +
           "        \"reader\": {\n" +
           "          \"name\": \"xxx\",\n" +
           "          \"parameter\": {}\n" +
           "        },\n" +
           "        \"writer\": {\n" +
           "          \"name\": \"hdfswriter\",\n" +
           "          \"parameter\": {\n" +
           "            \"defaultFS\": \"hdfs://<namenode>:9000\",\n" +
           "            \"fileType\": \"orc\",\n" +
           "            \"path\": \"/user/hive/warehouse/ta.db/<table>/$pt=<partition_val>\",\n" +
           "            \"fileName\": \"ta\",\n" +
           "            \"column\": [],\n" +
           "            \"writeMode\": \"nonConflict\",\n" +
           "            \"fieldDelimiter\": \"\\t\",\n" +
           "            \"compress\": \"SNAPPY\"\n" +
           "          }\n" +
           "        }\n" +
           "      }\n" +
           "    ]\n" +
           "  }\n" +
           "}";


   static {
      SUPPORT_SOURCE_MAP.put("mysql","mysqlreader");
      SUPPORT_SOURCE_MAP.put("ftp","ftpreader");
      SUPPORT_SOURCE_MAP.put("txtfile","txtfilereader");
      SOURCE_HIVE_COL_TYPE_MAP.put("varchar",      "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("string",       "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("char",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("tinytext",     "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("text",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("mediumtext",   "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("longtext",     "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("tinyblob",     "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("blob",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("mediumblob",   "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("longblob",     "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("enum",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("binary",       "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("varbinary",    "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("json",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("tinyint",      "int");
      SOURCE_HIVE_COL_TYPE_MAP.put("smallint",     "int");
      SOURCE_HIVE_COL_TYPE_MAP.put("mediumint",    "int");
      SOURCE_HIVE_COL_TYPE_MAP.put("int",          "int");
      SOURCE_HIVE_COL_TYPE_MAP.put("integer",      "int");
      SOURCE_HIVE_COL_TYPE_MAP.put("long",         "bigint");
      SOURCE_HIVE_COL_TYPE_MAP.put("bigint",       "bigint");
      SOURCE_HIVE_COL_TYPE_MAP.put("bit",          "bigint");
      SOURCE_HIVE_COL_TYPE_MAP.put("real",         "double");
      SOURCE_HIVE_COL_TYPE_MAP.put("float",        "double");
      SOURCE_HIVE_COL_TYPE_MAP.put("double",       "double");
      SOURCE_HIVE_COL_TYPE_MAP.put("decimal",      "double");
      SOURCE_HIVE_COL_TYPE_MAP.put("numeric",      "double");
      SOURCE_HIVE_COL_TYPE_MAP.put("date",         "date");
      SOURCE_HIVE_COL_TYPE_MAP.put("datetime",     "timestamp");
      SOURCE_HIVE_COL_TYPE_MAP.put("timestamp",    "timestamp");
      SOURCE_HIVE_COL_TYPE_MAP.put("time",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("year",         "string");
      SOURCE_HIVE_COL_TYPE_MAP.put("bool",         "boolean");
      SOURCE_HIVE_COL_TYPE_MAP.put("boolean",      "boolean");
   }
}
